home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Arsenal - The Cutting Edge of Hacking / Hacker's Arsenal - The Cutting Edge of Hacking.iso / texts / gtmhh / gtmhh5-2.txt < prev    next >
Text File  |  2002-01-31  |  27KB  |  590 lines

  1. _________________________________________________________
  2.  
  3. Guide to (mostly) Harmless Hacking
  4.  
  5. Vol. 5 Programmers' Series
  6.  
  7. No. 2: Shell Programming: an Exploit Explained, Part 1
  8. _________________________________________________________
  9.  
  10. by Carolyn Meinel <cpm@rt66.com> and BOFH <blips@cryptotek.happyhacker.org>
  11. (finger us for important security tips!)
  12.  
  13.     "What?" you wonder. "Another GTMHH on shell programming?"  Some people
  14. complained about the first of this GTMHH Programming Series because it
  15. didn't look like it had much to do with breaking into computers.  I hope you
  16. weren't one of those d00dz, because to run almost any exploit program, you
  17. need to understand shells and shell programming.
  18.  
  19.     Of course that also means you must have a shell account.  To find out how
  20. to get one, see the GTMHHs on "How to Get a Good Shell Account" at
  21. http://www.happyhacker.org.
  22.  
  23. =========================================================
  24. In this Guide you will learn:
  25.  
  26. * Why shell programming is important
  27. * The t shell (tcsh) and where to get it
  28. * How to customize your login shell script to make it:
  29.     easier to use
  30.     more secure
  31.     more phun:)
  32. * How to discover all available Unix commands
  33. * The C language compiler
  34. * An exploit explained: 
  35.     how to break into a computer in one easy shell script
  36. * How to explore a computer from inside a shell account
  37. * How to read email directly from the mail spool
  38. * Library programs
  39. =========================================================
  40.  
  41. WHY SHELL PROGRAMMING IS IMPORTANT
  42.  
  43.     We are doing yet more on Unix shells because almost any serious break-in
  44. program does its deed from inside a Unix shell. This is a difficult subject
  45. to teach because there are many varieties of Unix and many Unix shells.
  46. There also is that big unknown called "library functions."  Most exploit
  47. programs use many library functions.  If the computer on which you have a
  48. shell account doesn't have the required compiler or libraries, you can't run
  49. exploits.
  50.  
  51. ===========================================================
  52. Newbie Note:  This Guide uses the following concepts:
  53. * Unix shell:  A program that provides you with a wonderful storehouse of
  54. commands which it turns into instructions that your computer can understand.
  55. The same Unix operating system may accept different commands depending on
  56. what shell you use.  And different flavors of Unix (Linux, Sun OS, Solaris,
  57. AIX, Irix, FreeBSD, etc.) offer different sets of commands that you can use.
  58. You can also create your own shell commands -- something this Guide will
  59. teach you.
  60. * Interpreted programs: Your computer reads and performs your commands line
  61. by line.  This kind of program is easy to write and use, but slow.
  62. * Compiled programs: A compiler reads the commands line by line, figures out
  63. how to run these commands fast, and writes them into a compiled program.
  64. This kind of program is harder to make.  But once compiled, it runs much
  65. faster than an interpreted program.
  66. * Script: A sequence of commands which is interpreted rather than compiled.
  67. The most common scripts you will create or use in hacking are shell scripts
  68. and Perl programs.  A shell script is a series of Unix commands that are
  69. automatically executed (run) when you simply enter the name you gave to that
  70. script. What this means is that each script becomes a new Unix command for
  71. you to use.
  72. * Library functions and other library programs:  These are compiled programs
  73. that your computer stores which may be used by many other programs.  This
  74. saves disk space and programming time because each program that uses the
  75. instructions of a library program can simply call it from the library.
  76. * Binaries: These are the kind of files made by compilers.  A binary can be
  77. an entire program, or just a portion of a program used by many other
  78. programs (for example the library functions).
  79. ===========================================================
  80.  
  81.     There is no way this Guide -- or even a big, fat Unix manual -- could tell
  82. you all you may wish to know about the flavor of Unix you are using and its
  83. many shells, and all the library programs the exploits you want to run might
  84. use.  So at this point in the Programmers' Series we concentrate on showing
  85. you how to discover what the shells, compilers and library programs of your
  86. account will allow you to do.
  87.  
  88.     Besides, you may discover your shell account is hopelessly crippled.  Some
  89. Internet service providers are so afraid of hackers that they disable the
  90. use of compilers and put the library programs off limits.  After reading
  91. this Guide, you will appreciate why they do this.  You will also understand
  92. what to look for in a good shell account.  This may even inspire you to
  93. install Unix on your home computer so your skills will be the only limit on
  94. your system.
  95.  
  96. ============================================================
  97. DISCLAIMER (from BOFH):
  98. The information shown in this Guide is known to work with Linux, OpenBSD,
  99. FreeBSD, SunOS and Solaris.  The instructions of this Guide may not work
  100. with other flavors of Unix.  Please note that I'm not a technical writer,
  101. nor do I plan on doing this for a living.  
  102. I'm just attempting to pass on a bit of knowledge.  If someone finds a
  103. mistake, gleaming error or typo, do me a favor...  
  104.  
  105. bite me. 
  106. ============================================================
  107.  
  108. THE T SHELL (TCSH) AND WHERE TO GET IT
  109.  
  110.     This Guide will concentrate on only one Unix shell: the T shell (tcsh).
  111. That is shorthand for TENEX C Shell, an enhanced version of the Berkeley csh
  112. (C shell).
  113.  
  114.     Tcsh is the most powerful shell for people who wish to learn about every
  115. command they have the power to use.  Also, it is easy for spastic typists
  116. (like me -- Carolyn) to use.  To delete messed up stuff, just backspace!  To
  117. repeat a command, just use the up arrow to get to it.  
  118.  
  119.     The very first thing you need to do is find out if you have tcsh.  Try the
  120. following commands:
  121.     which tcsh
  122.     whereis tcsh
  123.     locate tcsh
  124.  
  125.   As a last result, you can try "find".  But be warned, many sysadmins don't
  126. like that command because it is slow and disk intensive.  The find command
  127. can put a serious lag on the machine.  
  128.   
  129.       Once you find where your tcsh is, make sure it's a "valid shell".  This
  130. can be done by checking whether it is in the "/etc/shells" file. This may be
  131. done with the command:
  132.   
  133. ->grep tcsh /etc/shells  
  134.  
  135.       (Note: throughout this Guide, "->" represents your command prompt.) If
  136. you get back something like:
  137.  
  138. /bin/tcsh
  139.  
  140.       Then you can safely use tcsh.  If you don't get anything back, then I
  141. (BOFH) suggest you contact your ISP and ask them to install it and add it to
  142. the valid shells list.  Yes, you can compile and install your own version.
  143. But if your shell is _not_ listed in the valid shells file, you may run into
  144. difficulties using programs such as ftp (incoming ftp) since many ftp
  145. daemons check to see if the user has a valid shell before logging in.
  146.   
  147.       If you're not grep savvy, try just `cat`ing the file:  
  148.  
  149. ->cat shells
  150.  
  151.     This should give you something that looks like:
  152. /bin/sh
  153. /bin/bash
  154. /bin/tcsh
  155. /bin/csh
  156. /bin/zsh
  157. /bin/ash
  158.  
  159.       If you discover tcsh in that file, at the prompt in your Unix shell
  160. account, simply type "tcsh" and play with it for awhile.  If you find that
  161. you prefer tcsh over your current shell, you can use the "chsh" command to
  162. make it your primary shell so that everytime you log in, you will already be
  163. in tcsh:
  164.  
  165. ->chsh tcsh
  166.  
  167.     This should give the result:
  168.  
  169. Changing login shell for cpm on mack.
  170. Old shell: /bin/bash
  171. New shell: /bin/tcsh
  172.  
  173. ============================================================
  174. Evil genius tip: Don't have tcsh?  Do you run some sort of Unix on your home
  175. computer?  Then you can install it.  To find a tcsh that will run under your
  176. version of Unix, do a Web search.  For example, for one that runs on almost
  177. any type of Linux, you will probably be able to use the tcsh at the Debian
  178. Linux Web site, http://www.debian.org.
  179.  
  180. Of course you will have to compile it, but if you are an evil genius you
  181. either already know how to do that, or will figure out enough from this
  182. Guide to successfully compile tcsh.
  183. ============================================================
  184.  
  185. HOW TO CUSTOMIZE YOUR LOGIN SHELL SCRIPT
  186.  
  187.     BOFH points out that in the world of vanilla Unix, different shells have
  188. different startup files.  For example:
  189.  
  190.   bash: .profile
  191.   sh:   .profile
  192.   csh:  .cshrc
  193.   tcsh: .cshrc
  194.   zsh:  $ZDOTDIR/.zprofile and/or $ZDOTDIR/.zshrc
  195.  
  196.       I [BOFH] could go on with the different shells out there, but these are
  197. the most common.
  198.   
  199.       btw...
  200.       There's even an lsh which emulates a doslike environment.  It sorta kinda
  201. sucks because if you're on a *nix ("*nix" stands for all the kinds of
  202. Unixes) system you want to use a *nix like shell but it's fun to use as a prank.
  203.  
  204.       Most all of these startup files read the files .login and .logout.
  205.  
  206.     Let's assume you have tcsh. The first thing you may wish to do is customize
  207. it.  It would be really shameful for a hacker like you or me to have an
  208. ordinary shell. Here's how you can see how your shell is set up.  The
  209. settings for tcsh are in a file named ".cshrc".  This is a shell script, a
  210. program consisting of a series of Unix shell commands. To read what is in
  211. it, give the command:
  212.  
  213. ->cat .cshrc|more
  214.  
  215. (Or give the command "more .cshrc".  The Unix motto is "There's more than
  216. one way to do it.")
  217.  
  218.     This will display the contents of this script on your monitor. Following is
  219. an example of the commands in a good .cshrc script:
  220.  
  221. echo "-------------------------------------------"
  222. echo "To err is human..."
  223. echo "    To get caught is just plain stupid..."
  224. echo "                                Fatal Error"
  225. echo "-----------Big brother is watching----------"
  226.  
  227. if (! ${?hostname} ) setenv hostname 'fubar'
  228.  
  229. umask 076
  230.  
  231. set path=( ~/bin /usr/local/bin /bin /usr/bin /usr/local/sbin )
  232. set path=( $path /usr/openwin/bin /usr/X11/bin /usr/local/X11/bin )
  233. set path=( $path /usr/ucb /usr/libexec /usr/etc /etc /usr/games )
  234. set path=( $path /usr/sbin )
  235.  
  236. setenv host `uname -n`
  237. setenv WWW_HOME http://www.fubar.com/
  238. setenv LD_LIBRARY_PATH "/usr/openwin/lib:/usr/local/X11/lib:/usr/X11/lib"
  239. setenv MANPATH "/usr/man:/usr/share/man:/usr/local/man"
  240. setenv VISUAL pico
  241. setenv EDITOR pico
  242. setenv PGPPATH ~/.pgpdir
  243.  
  244. mesg y
  245.  
  246. #set autologout=(0 40)
  247.  
  248. set exinit 
  249. set history=40
  250. set implicitcd
  251. set listjobs
  252. set listlinks
  253. set listjobs=long
  254. set noclobber
  255. set prompt="%U\n(`whoami`) fubar:%u \n%~ %# "
  256. set tperiod=1
  257. set rmstar
  258. set watch=(1 friend1 any friend2 any enemy1 any enemy2 any)
  259.  
  260. unset autologout
  261.  
  262. if ($?USER == 0 || $?prompt == 0) exit
  263.  
  264. alias a                 'alias | more'
  265. alias cd                'cd  \!*'
  266. alias check             'last | grep -v fubar.com | grep -v ftp | grep -v "^U"'
  267. alias cp                'cp -i -p'
  268. alias cls               'clear'
  269. alias dd                'ls -lgF \!* | more'
  270. alias ddm               'ls -lgF \!* | more'
  271. alias elm               'pine'
  272. alias jobs              'jobs -l'
  273. alias ld                'ls -ld $1'
  274. alias ls                'ls -F'
  275. alias pico              'pico -w -z'
  276. alias port              'ps -aux | grep $1'
  277. alias quit              'exit'
  278. alias scr               'source .cshrc;rehash'
  279. alias su                "ksu"
  280. alias sz                'sz -w 2048'
  281. alias w                 'w|sort|more'
  282. alias who               'who|sort|more'
  283. alias whois             'whois -h rs.internic.net'
  284. alias viman             'man \!$ | col -b > /tmp/myman$$;vi /tmp/myman$$;rm
  285. /tmp/myman$$'
  286. /usr/lib/sendmail x@techbroker.com < .junk
  287.  
  288. HOW TO MAKE YOUR SHELL MORE SECURE
  289.  
  290.     If you really consider yourself a hacker, you may choose to change your
  291. .cshrc to make it more secure.  Here's how to rewrite your .cshrc:
  292.  
  293. 1) Just in case you mess up and don't care to admit to tech support at your
  294. ISP that you have been messing with .cshrc, the first thing you should do is
  295. save it with a new name.  One way to do this is to give the command:
  296.  
  297. cp .cshrc .cshrc.old
  298.  
  299.     Then if you don't like the results of this exercise, you can fix it by just
  300. giving the command:
  301.  
  302. cp .cshrc.old .cshrc
  303.  
  304. 2) Now you are ready to change .cshrc.  Give the command "pico .cshrc"
  305. (substitute "vi" or "emacs" if you prefer those editors).  This opens the
  306. program that runs every time you start up your C shell.
  307.  
  308. 3) Here's something good to change.  See all those commands above that begin
  309. with "alias"?  Those are commands that allow you to run complicated commands
  310. by only typing in one letter or word.  Enter those aliases in you login
  311. script and see how you like them.  In the case of the  alias "check,"
  312. substitute the domain name of the computer you are using for "fubar.com".
  313.  
  314. 4) Do you wish to be able to easily access lots of good commands? That is
  315. what the "set path" command is for.  Good paths depend on the flavor of Unix
  316. you're running.  Good generic paths could be:
  317.  
  318. set path=( ~/bin /usr/local/bin /bin /usr/bin /usr/local/sbin )
  319. set path=( $path /usr/openwin/bin /usr/X11/bin /usr/local/X11/bin )
  320. set path=( $path /usr/ucb /usr/libexec /usr/etc /etc /usr/games )
  321. set path=( $path /usr/sbin )
  322.  
  323.       This will have some erroneous directories but it's generic and something
  324. you could use on Linux, FreeBSD, OpenBSD, Sun OS and Solaris.  With other
  325. flavors, your mileage may vary.
  326.  
  327. 5) When you are done editing, here's how pico saves it:
  328.  
  329.     * hold down the control key and hit the letter "x"
  330.     * pico asks, "Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?"
  331. Hit the "y" key to save it.
  332.     * pico asks "File Name to write : .cshrc" Just hit enter.  Your login file
  333. must be named ".cshrc" for it to run whenever you log in.
  334.  
  335. ============================================================
  336. Evil genius tip:  Want to be a hacker?  Take a serious look at learning
  337. "vi".  It is a quick and powerful Unix editor that can do tedious tasks in a
  338. short amount of time.  Head down to your local book store (or
  339. http://www.amazon.com) and pick up a good vi book.  Two to look for are:
  340. "Unix in a Nutshell" by O'Reilly (ISBN: 1-56592-001-5), and "Vi" by O'Reilly
  341. ============================================================
  342.  
  343. ============================================================
  344. Evil genius tip:  Are you a serious programmer?  Do you plan to become a
  345. serious programmer? If your .cshrc is missing anything in the example script
  346. above, try adding those commands.
  347. ============================================================
  348.  
  349.     Now, by setting aliases for your shell, you have made it easier to use, and
  350. also more secure.  Try out the aliased commands "w", "who", and "check". The
  351. first two tell you who is currently logged into shell accounts on the same
  352. computer you are on.  "Check" shows you the log of whoever has logged into
  353. the computer you use from telnet or ssh from outside that computer system.
  354. If you see an unusual pattern of logins, you may suspect there is a problem.
  355.  
  356.     Here's how these commands work.  I [Carolyn] am using one of our Hacker
  357. Wargame computers for the example below so you will get a chance to see how
  358. we find out whether there has been an intruder in my account.
  359.  
  360.     Netstat is really great because it tells you so much:
  361.  
  362. Active Internet connections
  363. Proto Recv-Q Send-Q  Local Address    Foreign Address        (state)
  364. tcp        0      0  cryptotek.http   sol7.cs.wisc.edu.33089 FIN_WAIT_2
  365. tcp        0      0  cryptotek.http   sol7.cs.wisc.edu.33088 FIN_WAIT_2
  366. tcp        0     20  cryptotek.ssh    pmd05.rt66.com.1753    ESTABLISHED
  367. Active UNIX domain sockets
  368. Address  Type   Recv-Q Send-Q    Inode     Conn     Refs  Nextref Addr
  369. f05e7f00 dgram       0      0        0 f03dcf14        0 f03dcb14
  370. f05f9200 dgram       0      0        0 f03dcf14        0 f03dcd14
  371. f05e9600 dgram       0      0        0 f03dcf14        0 f03dcd94
  372. f05eba00 dgram       0      0        0 f03dcf14        0        0
  373. f05a9000 dgram       0      0 f05ab680 0 f03ecc94      0 /var/run/log
  374.  
  375.     This readout tells us is that a guy from the University of Wisconsin is
  376. reading our Web site at http://cryptotek.happyhacker.org, while I am logged
  377. in with an ssh (Secure Shell, which encrypts my communications) connection.
  378.  
  379.     The commands "w" and "who" only tell you who is actually logged into a
  380. shell account and what they are doing just now. They both identify the same
  381. people, but give somewhat different information on their activities.  Here's
  382. a "w" command readout:
  383.  
  384. 1:05PM  up 2 days, 17:42, 2 users, load averages: 0.00, 0.00, 0.00
  385. USER     TTY FROM              LOGIN@  IDLE WHAT
  386. cryptik  p0  206.206.108.7     1:02PM     -  (pine)
  387. cmeinel  p1  pmd05.rt66.com   12:31PM     - w
  388.  
  389.     This means Cryptik is in his shell account reading his email using the Pine
  390. program while I (Carolyn) am snooping on him with the "w" command.
  391.  
  392.     If your ISP has logs readable by users, that alias in your .cshrc named
  393. "check" will tell you everyone who has logged into their shell accounts lately:
  394.  
  395. cmeinel  ttyp0    152.172.76.111   Thu Apr 23 14:25 - 16:30  (02:05)
  396. (snip)
  397. cryptik  ttyp0    206.206.108.7    Thu Apr 23 13:02 - 13:06  (00:04)
  398. mrcurt   ttyp1    152.166.28.22    Thu Apr 23 01:23 - 02:02  (00:38)
  399. (snip)
  400. cryptik  ttyp0    152.167.87.187   Wed Apr 22 19:18 - 19:20  (00:02)
  401. cryptik  ttyp0    152.173.170.182  Wed Apr 22 17:55 - 17:56  (00:00)
  402. root     ttyv0                     Wed Apr 22 17:02 - 17:04  (00:02)
  403. cryptik  ttyp0    152.171.172.203  Wed Apr 22 15:25 - 15:29  (00:03)
  404. protocol ttyp1    152.204.20.98    Wed Apr 22 01:43 - 01:59  (00:16)
  405. cryptik  ttyp0    152.170.244.211  Tue Apr 21 23:41 - 02:28  (02:47)
  406. cmeinel  ttyp1    bofh.foobar.org  Tue Apr 21 22:09 - 22:17  (00:08)
  407. xmyth    ttyp0    152.203.67.27    Tue Apr 21 18:11 - 18:12  (00:00)
  408. (snip)
  409. 420smk   ttyp0    152.172.97.237   Tue Apr 21 14:35 - 14:36  (00:01)
  410. root     ttyv0                     Tue Apr 21 14:03 - 14:04  (00:00)
  411. root     ttyp2    152.171.159.158  Tue Apr 21 01:25 - 02:10  (00:45)
  412. cryptik  ttyp1    206.206.108.7    Tue Apr 21 00:24 - 00:25  (00:00)
  413. skullz   ttyp1    152.166.74.235   Mon Apr 20 23:55 - 23:59  (00:04)
  414. skullz   ttyp1    152.166.74.235   Mon Apr 20 23:48 - 23:53  (00:05)
  415. cryptik  ttyp0    152.171.255.221  Mon Apr 20 23:24 - 01:33  (02:08)
  416. cryptik  ttyp0    152.167.139.204  Mon Apr 20 23:16 - 23:16  (00:00)
  417. cmeinel  ttyp1    152.170.227.210  Mon Apr 20 22:17 - 22:19  (00:02)
  418. (snip)
  419.  
  420.     Aha! Now you know the handles of the folks that have been using ftp or
  421. logging into shell accounts from outside the ISP (Rt66) hosting this
  422. computer lately. 
  423.  
  424.     That root login with no IP address after it, was done from the console.
  425. That means someone was actually physically at the keyboard to log in.  The
  426. numbers after the other handles are the IP addresses from which they came
  427. in.  For example, "cmeinel  ttyp1    152.170.227.210" means I came in from
  428. an America Online dialup!  (To see what those IP numbers mean, read the
  429. GTMHH "How to Map the Internet" for lots of ways to figure them out.)
  430. Fortunately, I remember telneting into my account from an AOL dialup that
  431. time, so it's cool.
  432.  
  433.     Now if I were to see my user name on this list at a time that I know I
  434. didn't log in, I would know someone has gotten my password and is making
  435. merry with my account!  That IP number would also tell me where Mr. Baddie
  436. is coming from (unless he or she is IP spoofing.) 
  437.  
  438. =======================================================================
  439. Newbie note:  IP spoofing is a way to fake your IP address.  Many computer
  440. criminals use it to hide their identity.  If one of these criminal types try
  441. to tell you this technique really works, please think twice.  There are
  442. commercially available sniffer programs that identify the true IP address
  443. even though the hacker is using an IP spoofing program.  See
  444. http://www.iss.net; http://www.engarde.com; and http://www.engarde.com.
  445. =======================================================================
  446.  
  447.     So -- what's this?  The log file says cmeinel telneted in from
  448. bofh.fubar.com!  I [Carolyn] know that computer. "BOFH" stands for the
  449. owner's handle, Bastard Operator from Hell.  Actually I was expecting that.
  450. He promised me a prank program or two in exchange for use of my account.
  451. Since this is an account on a Hacker Wargame computer, I said "what the
  452. heck."  Besides, I would trust anyone with such a neato handle.
  453.  
  454.     But, oh, my, look at this!
  455.  
  456. cmeinel  ttyp0    152.172.76.111   Thu Apr 23 14:25 - 16:30  (02:05)
  457.  
  458.     Who is this cmeinel who logged into my account from America Online for over
  459. two hours?  Wasn't me!  Maybe this individual will soon be able to use
  460. access to my shell account to get root and be the next Hacker Wargame
  461. winner!  Nah, I'll make it hard and change my password.  The command is
  462. simply "passwd." That's what you should do often anyhow, and definitely do
  463. whenever you discover an intruder was in your account.
  464.  
  465.     You probably would like to know exactly how that "check" command works.
  466. BOFH points out that the "last" command (give command "man 1 last" to learn
  467. more) shows the last logins that are usually stored in the wtmp file. Some
  468. ISP's rotate this file while others just leave it be.  The "last" command
  469. used by itself would show all logins to the 
  470. current machine since the creation of the wtmp file.  
  471.  
  472.        The command "grep" is a powerful line/pattern matching utility.  (Give
  473. command "man 1 grep" for more info).  The '-v' switch tells grep to filter
  474. out the following regular expression ("regular expressions" could use a
  475. series of GTMHHs to explain the concept itself).  In the above example, we
  476. are filtering out "fubar.com", "ftp", and anything starting with 'U'.  (The
  477. "^" signifies "starting with").  In this case, the "grep -v ^U" portion is
  478. used to grep out (discard) uucp (a communications protocol used for
  479. transmitting Usenet posts) entries since Fubar.com uucp accounts begin with
  480. "^U".  Your Internet service provider, however, may identify Usenet posts
  481. differently.
  482.  
  483.        Commands that may work better on your account than those used in the
  484. "check" alias above may be:
  485.  
  486.    last -200 | grep _your_user_name_here | more 
  487.  
  488.      - This shows the last 200 logins by your username, and pipes it to the
  489. "more" command.  This makes it easier to read if your terminal program
  490. doesn't allow you to scroll back.
  491.  
  492.    last -200 | grep -v _your_user_name_here | more  
  493.  
  494.      - This shows the last 200 logins of everyone except your username, 
  495. piping it to the "more" command.
  496.  
  497.     What are some other things you may add to your .cshrc script to make your
  498. account more secure?  Do you have friends or enemies that you wish to watch
  499. for when you are logged on?  Add this command to .cshrc:
  500.  
  501. set watch=(1 myfriend1 any myfriend2 any myenemy1 any myenemy2 any)
  502.  
  503.     Substitute the user names of your friends/enemies for myfriend etc.  If you
  504. use a small ISP, a newbie may wish to change the watch entry to:
  505.  
  506.   set watch=(1 any any)
  507.  
  508.       That will watch for logins every 1 second for any username.  On a slow
  509. system where resources are limited, change "1" to "5".
  510.  
  511.     If you are like me [Carolyn] and have lots of people trying to break into
  512. your account, you can also set up a warning system.  
  513.  
  514. 1) Use pico to create a file named ".junk" containing the sentence "Someone
  515. used my shell account."
  516.  
  517. 2) Bring up .cshrc in an editor and add this line: "/usr/lib/sendmail
  518. x@techbroker.com < .junk" (for "x@techbroker.com" substitute an email
  519. address of yours that is NOT the one for your shell account.  If you are a
  520. hacker you surely do have more than one email account, right?)
  521.  
  522.     WARNING: This command varies according to the configuration of your ISP.
  523. You might have to substitute a different path for "sendmail" (use command
  524. "whereis sendmail" to find it), or substitute mail for sendmail, etc. etc.
  525. If you can't make this command work, DON'T EMAIL US! Only tech support at
  526. your ISP can answer your questions.
  527.  
  528. 3) Save the new .cshrc file.
  529.  
  530.     Why send this warning to a different email account?  An intruder can simply
  531. delete your warning email if it goes back to your shell account.  You can
  532. get free email accounts at Hotmail, Yahoo, and several other places on the
  533. Web.  
  534.  
  535.     Or get one of those email accounts that notifies you by pager the instant
  536. your warning email arrives.  Of course, that can be a real pain having your
  537. beeper go off every time you log into your own account!  But we are showing
  538. you this trick to give you an idea of how systems administrators can find
  539. out instantly when an intruder gets in.
  540.  
  541.     Here's what that shell script sends me whenever someone uses tcsh in my
  542. account:
  543. Received: from Rt66.com (198.59.162.1)
  544.     by mail02.rapidsite.net (8.8.5/8.8.5) with ESMTP id NAA24145
  545.     for <x@techbroker.com>; Thu, 23 Apr 1998 13:08:38 -0400 (EDT)
  546. Received: (from cpm@localhost)
  547.     by Rt66.com (8.8.7/8.8.6) id LAA23890
  548.     for x@techbroker.com; Thu, 23 Apr 1998 11:05:51 -0600 (MDT)
  549. Date: Thu, 23 Apr 1998 11:05:51 -0600 (MDT)
  550. From: cpm <cpm@Rt66.com>
  551. Message-Id: <199804231705.LAA23890@Rt66.com>
  552. X-Loop-Detect: 1
  553.  
  554. Someone used my shell account.
  555.  
  556. HOW TO MAKE YOUR SHELL MORE PHUN
  557.  
  558.     Next, I wage a little psychological warfare.  OK, I admit it, this part is
  559. lame, but fun. So hold your flames. 
  560.  
  561. 1) Open .cshrc with your favorite editor.
  562.  
  563. 2) Insert something like this:
  564.  
  565. echo -------------------------------------------
  566. echo To err is human...
  567. echo     To get caught is just plain stupid...
  568. echo                                 Fatal Error
  569. echo -----------Big brother is watching----------
  570.  
  571. (This Guide continued in Part 2...)
  572.  
  573. _______________________________________________________________________
  574. Where are those back issues of GTMHHs and Happy Hacker Digests? Check out
  575. the official Happy Hacker Web page at http://www.happyhacker.org.
  576. We are against computer crime. We support good, old-fashioned hacking of the
  577. kind that led to the creation of the Internet and a new era of freedom of
  578. information. So don't email us about any crimes you have committed!
  579. To subscribe to Happy Hacker and receive the Guides to (mostly) Harmless
  580. Hacking, please email hacker@techbroker.com with message "subscribe
  581. happy-hacker" in the body of your message. 
  582. Copyright 1998 Carolyn P. Meinel <cmeinel@techbroker.com> and BOFH. You may
  583. forward, print out or post this GUIDE TO (mostly) HARMLESS HACKING on your
  584. Web site as long as you leave this notice at the end.
  585. _________________________________________________________
  586. Carolyn Meinel
  587. M/B Research -- The Technology Brokers
  588. http://techbroker.com
  589.  
  590.